package it.polimi.jita.cp.block.pc;

import it.polimi.jita.cp.block.Output;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class PenaltyOutput extends Output {

	private final List<PenaltyInstant> instants = new ArrayList<>();

	private Double totExpPenalty = 0.0d;
	private Double totAsymptoticPenalty = 0.0d;

	public boolean addPenaltyInstant(PenaltyInstant penaltyInstant) {
		if (penaltyInstant.getAsymptoticPenalty() != null)
			totAsymptoticPenalty += penaltyInstant.getAsymptoticPenalty();

		totExpPenalty += penaltyInstant.getExpPenalty();
		return instants.add(penaltyInstant);
	}

	public List<PenaltyInstant> getPenaltyInstants() {
		return Collections.unmodifiableList(instants);
	}

	public Double getTotExpPenalty() {
		return totExpPenalty;
	}

	public Double getTotAsintoticPenalty() {
		return totAsymptoticPenalty;
	}

	public Double getAvgExpPenalty() {
		return totExpPenalty / instants.size();
	}

	public Double getAvgAsymptoticPenalty() {
		return totAsymptoticPenalty / instants.size();
	}

}
